package com.googlecode.intellimars.derby;

import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.Presentation;

public class DerbyControlAction extends AnAction {
    private DerbyPlugin derbyPlugin;

    public DerbyControlAction() {
        derbyPlugin = DerbyPlugin.getInstance();
    }

    public void actionPerformed(AnActionEvent e) {
        derbyPlugin.toggleState();
    }

    public void update(AnActionEvent event) {
        super.update(event);
        Presentation presentation = event.getPresentation();
        presentation.setIcon(derbyPlugin.getStateIcon());
        presentation.setText(derbyPlugin.getState());
    }
}
